import path from 'path';
import { ConnectionOptions, DataSourceOptions } from 'typeorm';

type OrmConfig = ConnectionOptions | DataSourceOptions;

/**
 * typeorm配置
 */
const ormConfig: OrmConfig = {
  type: 'mysql',
  host: 'localhost',
  port: 3306,
  username: 'root',
  password: '123456',
  database: 'test',
  timezone: 'Z',
  // 运行应用程序时实体与数据库同步
  synchronize: true,
  // logging: false,
  logging: ['query'],
  // 使用entities数组
  entities: [path.resolve(__dirname, '../entity/**/*.entity.ts')],
};

export { ormConfig, OrmConfig };
